package com.xz.demo.model;

/**
 * @author 张志航     
 * @version V1.0.0
 * @projectName design_mode
 * @title     ConcretePrototype   
 * @package    com.xz.demo.model  
 * @date   2019/11/29 16:38  
 * @explain
 */
// 重写Object的clone方法,这是Java的特性,注意: 重写clone方法后需要实现Cloneable接口,否则会报ClassNotSuppertedException异常
public class Concrete1Prototype implements Cloneable {

    private String attr;

    public String getAttr() {
        return attr;
    }

    public void setAttr(String attr) {
        this.attr = attr;
    }

    @Override
    public Concrete1Prototype clone() {
        try {
            return (Concrete1Prototype) super.clone();
        } catch (CloneNotSupportedException e) {
            System.out.println("Not supper cloneable");
        }
        return null;
    }
}
